﻿<%@ Page Language="C#" MasterPageFile="~/Site2.Master" AutoEventWireup="true" CodeBehind="Stock.aspx.cs" Inherits="DECOR.WebApp.Stock" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register assembly="IdeaSparx.CoolControls.Web" namespace="IdeaSparx.CoolControls.Web" tagprefix="cc2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphHeader" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMainMenu" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphTopMenu" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="cphTopContent" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="cphMain" runat="server">
</asp:Content>

<asp:Content ID="Content7" ContentPlaceHolderID="cphMainLeft" runat="server">
    Seleccione una Jerarquía:

<asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="upJerarquias"  runat="server">
    <ProgressTemplate>
        <img src="img/loading.gif" alt="Cargando" title="Cargando" />
    </ProgressTemplate>
</asp:UpdateProgress>

<div style="height:10px"></div>
<asp:UpdatePanel ID="upJerarquias" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
    <div id="jerarquiaDIV">
      <asp:TreeView ID="tvJerarquia" runat="server" NodeIndent="10" OnSelectedNodeChanged="tvJerarquia_SelectedNodeChanged"
                    ExpandDepth="1" OnTreeNodePopulate="tvJerarquia_TreeNodePopulate" >
        <SelectedNodeStyle Font-Underline="False" ForeColor="White" BackColor="ActiveCaption" />
        <NodeStyle Font-Names="Verdana" Font-Size="8pt" NodeSpacing="0px" HorizontalPadding="5px" />
      </asp:TreeView>
    </div>
</ContentTemplate>
</asp:UpdatePanel>

<div style="height:20px"></div>

Lista de Productos Añadidos:
<div style="height:10px"></div>
<asp:UpdatePanel ID="upMaterialesSelec" runat="server" UpdateMode="Conditional" >
    <ContentTemplate>
        <asp:DataList ID="dlMaterialesSelec" CssClass="tbl-detalle" runat="server" 
            CellPadding="4" Visible="true"
             ShowFooter="false" onitemcommand="dlMaterialesSelec_ItemCommand" >
            <HeaderTemplate>
                <tr>
                    <th colspan="2">
                        Materiales Seleccionados<br />
                        <asp:LinkButton ID="lnkCrearPedido" runat="server" Text="Continuar >>" ToolTip="Click para ir al doc de venta" PostBackUrl="~/DocVenta.aspx" />
                    </th>
                </tr>
                <tr><td style="height:20px; vertical-align:middle;" colspan="11"><hr /></td></tr>
            </HeaderTemplate>
            <ItemTemplate>
            <tr>
                <td style="text-align:center;">
                    <asp:ImageButton ID="ImageButton1" ImageAlign="Middle" ImageUrl="~/img/del.png" runat="server" CommandName="DelItem" ToolTip='<%# Bind("Posicion") %>' />
                </td>
                <td>
                    <asp:HiddenField ID="hidMaterialId" runat="server" Value='<%# Bind("CodMaterial") %>' />
                    <asp:Label ID="lblNomMaterial" runat="server" Text='<%# Bind("DescMaterial") %>' ToolTip='<%# Bind("CodMaterial") %>' />
                </td>
            </tr>
            </ItemTemplate>
            <FooterTemplate>
                <tr><td style="height:20px" colspan="11"></td></tr>
                <tr><td colspan="7">No se han seleccionado items...</td></tr>
            </FooterTemplate>
        </asp:DataList>
    </ContentTemplate>
</asp:UpdatePanel>

</asp:Content>

<asp:Content ID="Content8" ContentPlaceHolderID="cphMainBody" runat="server">

<asp:UpdatePanel ID="upMain" runat="server">
    <ContentTemplate>

        <table cellpadding="2" cellspacing="0">

            
            <tr>
                <td style="text-align: right;">
                    &nbsp;
                </td>
                <td style="text-align: right;">
                   Org Ventas
                </td>
                <td style="text-align: left; width:120px;">
                                        <asp:DropDownList ID="cmbOrgVentas" runat="server" 
                    OnSelectedIndexChanged="cmbOrgVtas_SelectedIndexChanged" 
                                                    AutoPostBack="false" />&nbsp; <asp:ImageButton ID="ibtnBuscar" runat="server" ImageAlign="Middle" ImageUrl="~/img/find.png" OnClick="ibtnBuscar_Click" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    
                </td>
                <td style="text-align: right;" visible="false">
                   
                </td>
                
                <td style="text-align: left;" visible="false"> 
                    <!--<asp:Label ID="lblOrgVentas" runat="server" /> -->
                    <asp:DropDownList ID="cmbCanalDist" runat="server" Visible="false" />
                     <!--<asp:Label ID="lblCanalDist" runat="server" Text="10" />-->
                </td>
            </tr>             
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="Label5" Text="Material" runat="server"></asp:Label>
                </td>
                <td style="text-align: right; width:120px;">
                    <asp:Label ID="Label6" Text="Código:" runat="server"></asp:Label>
                </td>
                <td>
                    <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server"
                        TargetControlID="txtCodMaterial" WatermarkText="código material...">
                    </cc1:TextBoxWatermarkExtender>
                    <asp:TextBox ID="txtCodMaterial" runat="server" CssClass="inputbox" Width="150px" 
                        MaxLength="18" ontextchanged="txtCodMaterial_TextChanged" AutoPostBack="true" 
                        AutoCompleteType="Search" />
                    <cc1:FilteredTextBoxExtender ID="fteCodMaterial" TargetControlID="txtCodMaterial" FilterType="Numbers" runat="server" />
                </td>
            </tr>
            
            <tr>
                <td style="text-align: right;">
                    &nbsp;
                </td>
                <td style="text-align: right;">
                    <asp:Label ID="Label7" Text="Codigo Antiguo:" runat="server"></asp:Label>
                </td>
                <td>
                    <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender3" runat="server"
                        TargetControlID="txtCodMaterialAntiguo" WatermarkText="código antiguo...">
                    </cc1:TextBoxWatermarkExtender>
                    <asp:TextBox ID="txtCodMaterialAntiguo" Text="" runat="server" CssClass="inputbox" Width="100" 
                        ontextchanged="txtMaterial_TextChanged" AutoPostBack="true" AutoCompleteType="None" />
                </td>
            </tr>
            
            <tr>
                <td style="text-align: right;">
                    &nbsp;
                </td>
                <td style="text-align: right;">
                    <asp:Label ID="Label2" Text="Descripción:" runat="server"></asp:Label>
                </td>
                <td>
                    <cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"
                        TargetControlID="txtMaterial" WatermarkText="buscar material...">
                    </cc1:TextBoxWatermarkExtender>
                    <asp:TextBox ID="txtMaterial" Text="" runat="server" CssClass="inputbox" Width="300" 
                        ontextchanged="txtMaterial_TextChanged" AutoPostBack="true" AutoCompleteType="None" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right; padding-left:100px;">
                    <asp:Label ID="Label1" Text="Centro:" runat="server"></asp:Label>
                </td>
                <td style="text-align: right;">
                    &nbsp;
                </td>
                <td>
                    <asp:DropDownList ID="cmbCentro" runat="server" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="Label3" Text="Almacen:" runat="server"></asp:Label>
                </td>
                <td style="text-align: right;">
                    &nbsp;
                </td>
                <td>
                    <asp:DropDownList ID="cmbAlmacen" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="3" style="text-align: center;">            
                   
                 </td>
            </tr>
            <tr>
                <td colspan="3" style="text-align: center;">
            
            <asp:LinkButton ID="lnkBuscarStock" runat="server" Text="Todos los materiales" OnClick="lnkBuscarStock_Click" />
        </td>
            </tr>
        </table>
     
   <div style="height:10px"></div>

        <cc2:CoolGridView ID="cgvMateriales" runat="server" Width="100%" Height="300px" 
                        OnRowCommand="cgvMateriales_RowCommand" OnDataBound="cgvMateriales_DataBound"
                        CssClass="tbl-materiales" AutoGenerateColumns="false" 
            Font-Size="12px">
            <Columns>
                <asp:ButtonField ButtonType="Image" HeaderText="Stk" CommandName="VerStock" HeaderStyle-Width="25"
                                HeaderStyle-HorizontalAlign="Center" 
                    ImageUrl="~/img/stock.png" >
                    <HeaderStyle HorizontalAlign="Center" Width="25px" />
                </asp:ButtonField>
                <%--<asp:ButtonField ButtonType="Image" HeaderText="EC" CommandName="VerStockEC" HeaderStyle-Width="25"
                                HeaderStyle-HorizontalAlign="Center" 
                    ImageUrl="~/img/stockec.png" >
                    <HeaderStyle HorizontalAlign="Center" Width="25px" />
                </asp:ButtonField>--%>
                <asp:ButtonField ButtonType="Image" HeaderText="" CommandName="AddItem" HeaderStyle-Width="25"
                                HeaderStyle-HorizontalAlign="Center" 
                    ImageUrl="~/img/addItem.png" Visible="false" >
                    <HeaderStyle HorizontalAlign="Center" Width="25px" />
                </asp:ButtonField>
                <asp:BoundField DataField="CodMaterialCorto" HeaderText="Material" 
                    ItemStyle-HorizontalAlign="Center" >
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:BoundField DataField="DescMaterial" HeaderText="Descripción" 
                    HeaderStyle-Width="250" >
                    <HeaderStyle Width="250px" />
                </asp:BoundField>
                <asp:BoundField DataField="CodUMedida" HeaderText="UM" HeaderStyle-Width="40" 
                    ItemStyle-HorizontalAlign="Center" >
                    <HeaderStyle Width="40px" />
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>
                <asp:BoundField DataField="Rendimiento" HeaderText="Rend." 
                    ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="65"  >
                    <HeaderStyle Width="65px" />
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="PrecioUnit" HeaderText="Pre. c/IGV" 
                    ItemStyle-HorizontalAlign="Right" DataFormatString="{0:0,0.00}" >
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="sStock" HeaderText="Stock" HeaderStyle-Width="120" 
                    ItemStyle-HorizontalAlign="Right" ItemStyle-BackColor="Wheat" 
                     >
                    <HeaderStyle Width="120px" />
                    <ItemStyle BackColor="Wheat" HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="Descontinuado" HeaderText="D" HeaderStyle-Width="20" 
                    ItemStyle-HorizontalAlign="Center" >
                    <HeaderStyle Width="20px" />
                    <ItemStyle HorizontalAlign="Center" />
                </asp:BoundField>
            </Columns>
            <HeaderStyle BackColor="Silver" />
            <BoundaryStyle BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px" />
        </cc2:CoolGridView>
    

    <asp:DataList ID="dlMateriales" runat="server" CellPadding="4" Visible="false"
        CssClass="tbl-materiales" onitemcommand="dlMateriales_ItemCommand" Width="100%"
        ShowFooter="false" ShowHeader="false" Font-Size="12px">
        <HeaderTemplate>
        </HeaderTemplate>
        <ItemTemplate>
            <td style="text-align:center;">
                <asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Middle" ImageUrl="~/img/stock.png" CommandName="VerStock" AlternateText="Stock" ToolTip='Ver Stock' />
            </td>
            <td style="text-align: left; width: 70%">
                <asp:HiddenField ID="hidMaterialId" runat="server" Value='<%# Bind("CodMaterial") %>' />
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("DescMaterial") %>' ToolTip='<%# Bind("CodMaterial") %>'></asp:Label>
            </td>
            <td style="text-align:center;">
                <asp:Label ID="Label4" runat="server" Text=' <%# Bind("CodUMedida") %>'></asp:Label>
            </td>
            <td style="text-align: center;">
                <asp:Label ID="lblRendimiento" runat="server" Text='<%# Bind("Rendimiento") %>'></asp:Label>
            </td>
            <td style="text-align: right; padding-right:5px;">
                <asp:Label ID="lblPrecioUnit" runat="server" Text='<%# Bind("PrecioUnit") %>'></asp:Label>
            </td>
        </ItemTemplate>
        <FooterTemplate>
            <td colspan="4">No se han encontrado materiales...</td>
        </FooterTemplate>
    </asp:DataList>
    </ContentTemplate>
</asp:UpdatePanel>


    <asp:UpdatePanel ID="upVerStock" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:Button id="btnShowPopup" runat="server" style="display:none;" />
        <cc1:ModalPopupExtender ID="popUpVerStock" runat="server" TargetControlID="btnShowPopup"
                        PopupControlID="pnlVerStock" CancelControlID="ibtnClosePopUp"
                        BackgroundCssClass="modalBackground" PopupDragHandleControlID="pnlTitulo" />

        <asp:Panel ID="pnlVerStock" runat="server" ScrollBars="Auto" Width="640px" Height="320px" CssClass="modalPopup">
            <asp:Panel ID="Panel1" runat="server" Width="640px" BackColor="Yellow" HorizontalAlign="Center">
                <asp:Label ID="lblStockEC" runat="server" Text="" BackColor="Yellow" />
            </asp:Panel>
            <asp:Panel ID="pnlTitulo" runat="server" Width="630px" BackColor="lightblue" HorizontalAlign="Center">
                <asp:Label ID="lblVerStock" runat="server" Text="Detalle de Stock" BackColor="lightblue" />
                <asp:ImageButton ID="ibtnClosePopUp" runat="server" ImageUrl="~/img/cancel16.png" ImageAlign="Right" />
            </asp:Panel>
            <asp:Panel ID="pnlCuerpo" runat="server" Width="620px" Height="290px" 
                EnableViewState="true" ScrollBars="Auto">
                <asp:GridView ID="gvStock" runat="server" CssClass="tbl-stock" Width="600px" AutoGenerateColumns="false" 
                        ShowFooter="true" onrowdatabound="gvStock_RowDataBound">
                    <Columns>
                        <asp:BoundField DataField="DescCentro" HeaderText="Centro" NullDisplayText="-" ItemStyle-Width = "90px" />
                        <asp:BoundField DataField="DescAlmacen" HeaderText="Almacén" NullDisplayText="-" ItemStyle-Width = "40px" />
                        <asp:BoundField DataField="CodLote" HeaderText="Lote" NullDisplayText="-"  ItemStyle-Width = "40px" />
                        <asp:BoundField DataField="sStockDisponible" DataFormatString="{0:0,0.000}" 
                                        ItemStyle-HorizontalAlign="Right" ItemStyle-BackColor="Wheat" 
                                        HeaderText="Stock Disponible" NullDisplayText="-" ItemStyle-Width = "40px" />
                   </Columns>
                    <FooterStyle BackColor="Wheat" />
                </asp:GridView>
            </asp:Panel>
        </asp:Panel>

        </ContentTemplate>                
    </asp:UpdatePanel>
    
    
    <asp:UpdatePanel ID="upVerStockEC" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:Button id="btnShowPopupEC" runat="server" style="display:none;" />
        <cc1:ModalPopupExtender ID="popUpVerStockEC" runat="server" TargetControlID="btnShowPopupEC"
                        PopupControlID="pnlVerStockEC" CancelControlID="ibtnClosePopUpEC"
                        BackgroundCssClass="modalBackground" PopupDragHandleControlID="pnlTituloEC" />

        <asp:Panel ID="pnlVerStockEC" runat="server" ScrollBars="Auto" Width="780px" Height="400px" CssClass="modalPopup">
            <asp:Panel ID="pnlTituloEC" runat="server" Width="778px" BackColor="lightblue" HorizontalAlign="Center">
                <asp:Label ID="lblVerStockEC" runat="server" Text="Detalle de Stock en curso" BackColor="lightblue" />
                <asp:ImageButton ID="ibtnClosePopUpEC" runat="server" ImageUrl="~/img/cancel16.png" ImageAlign="Right" />
            </asp:Panel>
            <asp:Panel ID="pnlCuerpoEC" runat="server" Width="779px" Height="375px" 
                EnableViewState="true" ScrollBars="Auto">
                <asp:GridView ID="gvStockEC" runat="server" CssClass="tbl-stockec" AutoGenerateColumns="false">
                    <Columns>
                        <asp:BoundField DataField="DescCentro" HeaderText="Centro" NullDisplayText="-" />
                        <asp:BoundField DataField="DescAlmacen" HeaderText="Almacén" NullDisplayText="-" />
                        <asp:BoundField DataField="CodLote" HeaderText="Lote" NullDisplayText="-" />
                        <asp:BoundField DataField="StockEnTransito" DataFormatString="{0:n}" ItemStyle-HorizontalAlign="Right" HeaderText="Stock en curso" NullDisplayText="-" />
                        <asp:BoundField DataField="StockDisponible" DataFormatString="{0:n}" ItemStyle-HorizontalAlign="Right" ItemStyle-BackColor="Wheat" HeaderText="Stock Disponible" NullDisplayText="-" />
                        <asp:BoundField DataField="FechaStock" DataFormatString="{0:dd/MM/yyyy}"  ItemStyle-HorizontalAlign="Center" HeaderText="Fecha Disponibilidad" NullDisplayText="-" />
                    </Columns>
                    <FooterStyle BackColor="Wheat" />
                </asp:GridView>
            </asp:Panel>
        </asp:Panel>

        </ContentTemplate>                
    </asp:UpdatePanel>

</asp:Content>



<asp:Content ID="Content9" ContentPlaceHolderID="cphFooter" runat="server">
</asp:Content>
